package com.cc.data_explore;

import atlantafx.base.theme.PrimerLight;
import com.cc.data_explore.gui.helper.StageHelper;
import com.cc.data_explore.gui.main.MainView;
import com.cc.data_explore.gui.main.MainViewModel;
import com.cc.data_explore.gui.main.WindowView;
import com.cc.data_explore.gui.main.WindowViewModel;
import de.saxsys.mvvmfx.FluentViewLoader;
import de.saxsys.mvvmfx.ViewTuple;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

/**
 * @author cc
 */
public class DataApplication extends Application {

    @Override
    public void start(Stage stage) {
        Thread.currentThread().setUncaughtExceptionHandler(new DefaultExceptionHandler(stage));
        Application.setUserAgentStylesheet(new PrimerLight().getUserAgentStylesheet());
        ViewTuple<WindowView, WindowViewModel> load = FluentViewLoader.fxmlView(WindowView.class).load();
        Parent view = load.getView();
        Scene scene = new Scene(view, 1280, 800);
        stage.setTitle("轻量级Excel工具");
        stage.setScene(scene);
        stage.setMinWidth(1024);
        stage.setMinHeight(768);
        StageHelper.addStage(StageHelper.MAIN_STAGE, stage);
        stage.setOnCloseRequest(t -> Platform.exit());
        Platform.runLater(() -> {
            stage.show();
            stage.requestFocus();
        });
    }
    public static void main(String[] args) {
        launch();
    }
}